﻿using Qr.Servce;
using System;
using System.Web.Mvc;

namespace Qr.Controllers {
    public class HomeController : Controller {

        private string accessToken {
            get {
                return AccessToken.GetToken();
            }
        }

        public ActionResult Index() {
            return View();
        }

        public JsonResult GetQrCode(Boolean isTemp, String sceneValue) {
            QrCode code = null;
            if (isTemp) {
                code = QrCode.GetTemporary(accessToken, sceneValue);
            }
            else {
                code = QrCode.GetPermanent(accessToken, sceneValue);
            }

            return Json(code.CodeUrl, JsonRequestBehavior.AllowGet);
        }
    }
}
